package br.com.gbvbahia.mybooks;

import java.io.Serializable;

import android.os.Bundle;
import br.com.gbvbahia.mybooks.fragment.AvaliarFragment;
import br.com.gbvbahia.mybooks.fragment.FragmentTransfer;
import br.com.gbvbahia.mybooks.fragment.ListarLivrosFragment;
import br.com.gbvbahia.mybooks.fragment.LivroCountFragment;
import br.com.gbvbahia.mybooks.modelos.LivroVO;

public class Avaliar extends ActivityMae implements FragmentTransfer {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.avaliar);
	}

	@Override
	public void updateFragment(int idFragmentToUpdate, Serializable obj) {
		switch (idFragmentToUpdate) {
		case R.layout.listar:
			AvaliarFragment avaliar = (AvaliarFragment) getSupportFragmentManager()
					.findFragmentByTag("avaliarfrag");
			avaliar.setLivro((LivroVO) obj);
			break;
		case R.layout.frag_avaliar:
			ListarLivrosFragment lista = (ListarLivrosFragment)  getSupportFragmentManager()
					.findFragmentByTag("listalivrosfrag");
			lista.atualizarView();
			LivroCountFragment count = (LivroCountFragment)  getSupportFragmentManager()
					.findFragmentByTag("contlivrosfrag");
			count.onResume();
			break;
		}
	}

}
